package com.example.auth3.service;

import com.example.auth3.mapper.SPrivilegeUserMapper;
import com.example.util.model.PrivilegeUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * 自定义service 用来查询用户信息
 * @author shangSshang
 */
@Service
public class PrivilegeUserService {
    private final Logger logger= LoggerFactory.getLogger(PrivilegeUserService.class);
	@Autowired
	private SPrivilegeUserMapper sPrivilegeUserMapper;
	
	@Cacheable(value="privilegeUser", key="'login_user'")
    public PrivilegeUser selectByPrimaryKey(String loginName) {
        logger.info("开始查询.....");
        try {
            Thread.sleep(3 * 1000l);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        PrivilegeUser privilegeUser=sPrivilegeUserMapper.getCurrentUserByloginName(loginName);
        logger.info(privilegeUser.toString());
        logger.info("查询结束......");

        return privilegeUser;
    }
	
}
